package com.lgl.scsheader.sameCityManage.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lgl.scsapi.base.dao.DaoSupport;
import com.lgl.scsapi.system.model.PageData;
import com.lgl.scsapi.system.model.ServiceOrder;
import com.lgl.scsapi.util.utils.Constants;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 同城订单service
 */

@Service("sameCityOrderService")
public class SameCityOrderService {
	@Resource(name = "daoSupport")
	private DaoSupport dao;

	/**
	 * 获取同城订单信息
	 * @param pd 订单参数
	 * @return 订单分页对象PageInfo
	 */
	public PageInfo pageServiceOrder(PageData pd, int pageNo, int pageSize){
		if (pageSize < 1){
			pageSize = Constants.PAGE_SIZE;
		}
		if (pageNo < 1){
			pageNo = 1;
		}
		String status = pd.getString("soStatus");
		if (status != null && status.contains(",")){
			pd.put("statusArray", status.split(","));
			pd.remove("soStatus");
		}
		PageHelper.startPage(pageNo,pageSize);
		List<ServiceOrder> orderListList = (List<ServiceOrder>) dao.findForList("ServiceOrderMapper.pageServiceOrder", pd);
		return new PageInfo(orderListList);
	}

	/**
	 * 获取城市订单总量
	 * @return 城市订单数据
	 */
	public List<PageData> listCityOrderTotal(){
		return (List<PageData>) dao.findForList("ServiceOrderMapper.listCityOrderTotal", null);
	}
	/**
	 * 获取订单总量/今天总量/昨天总量
	 * @return 订单数据集合
	 */
	public List<PageData> listTodayYesterdayTotal(){
		return (List<PageData>) dao.findForList("ServiceOrderMapper.listTodayYesterdayTotal", null);
	}

}